using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;

namespace InfiniTec.Security
{	/// <summary>
/// Exception thrown when a QueryCredentialDialog failed
/// </summary>
[Serializable]
public sealed class QueryCredentialDialogException : Exception
{
    private readonly QueryCredentialError _Error;
   
    public QueryCredentialError Error 
    {
        get { return _Error; }
    }

    public override void GetObjectData(SerializationInfo info, StreamingContext context)
    {
        base.GetObjectData(info, context);
            
        info.AddValue("Error", (int) _Error);
    }
    

    /// <summary>
    /// Initializes a new instance of the <see cref="QueryCredentialDialogException"/> class.
    /// </summary>
    public QueryCredentialDialogException() {}
	
    /// <summary>
    /// Initializes a new instance of the <see cref="QueryCredentialDialogException"/> class.
    /// </summary>
    /// <param name="message">The message.</param>
    /// <param name="error">The error which caused this exception</Param>
    public QueryCredentialDialogException(QueryCredentialError error, string message) : base(message) 
    {
        _Error = error;
    }
		
    /// <summary>
    /// Initializes a new instance of the <see cref="QueryCredentialDialogException"/> class.
    /// </summary>
    /// <param name="message">The message.</param>
    /// <param name="innerException">The inner exception.</param>
    /// <param name="error">The error which caused this exception</Param>
    public QueryCredentialDialogException(QueryCredentialError error, string message, Exception innerException) : base(message, innerException)
    {
        _Error = error;
    }
	
    /// <summary>
    /// Initializes a new instance of the <see cref="QueryCredentialDialogException"/> class.
    /// </summary>
    /// <param name="context">The <see cref="StreamingContext"/> to recreate the exception from.</param>
    /// <param name="info">The <see cref="SerializationInfo"/> to recreate the exception from.</param>
    private QueryCredentialDialogException(SerializationInfo info, StreamingContext context): base(info, context) 
    {
        _Error = (QueryCredentialError) info.GetInt32("Error");
    }
}
}
